@section('title')
	找律师 @parent
@show
@section('content')
	<div style="width:600px; margin:auto">
		<form method="post" id="js-form" action="">
		<table align="center" border="1">
			<th width="100">选择</th><th width="100">id</th><th width="100">姓名</th><th width="100">昵称</th><th width="100">律师</th><th width="100">备注</th>
			@foreach($data['users'] as $user)
			<tr  align="center">
				<td><input type="checkbox" name="userId[]" value="{{ $user['id'] }}"></td><td>{{ $user['id'] }}</td><td>{{ $user['realname'] }}</td><td>{{ $user['nikname'] }}</td><td>{{ $user['user_group_id'] }}</td><td></td>		
			</tr>
			@endforeach
		</table>
		
		<div>
		<br>
			<input type="hidden" name="_token" value="{{ csrf_token() }}" />&nbsp;&nbsp;
			<input type="button" onclick="ck(true)" value="全选">&nbsp;&nbsp;<input type="button" onclick="ck(false)" value="取消全选">&nbsp;&nbsp;
			<a href="javascript:void(0)" id="register">注册环信</a>&nbsp;&nbsp;
			<a href="javascript:void(0)" id="updatepass">更新密码</a>&nbsp;&nbsp;
			<a href="javascript:void(0)" id="deleteuser">删除环信用户</a>
		</div>
		</form>
		<div>
		<br>
		<a href="{{ route('easemob.users') }}">查看已注册环信用户</a>&nbsp;&nbsp;
		<a href="{{ route('easemob.noeasemob') }}">查看未注册环信用户</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<?php if($data['page']>1){?>
		<a href="?page={{$data['page']-1}}">上一页</a>&nbsp;&nbsp;
		<?php }if($data['page']<$data['total_page']){?>
		<a href="?page={{$data['page']+1}}">下一页</a>&nbsp;&nbsp;
		<?php }?>
		第<font color=red>{{$data['page']}}/{{$data['total_page']}}</font>页
		<br>
		</div>
	</div>
	<SCRIPT LANGUAGE="JavaScript">
function ck(b)
{
    var input = document.getElementsByTagName("input");

    for (var i=0;i<input.length ;i++ )
    {
        if(input[i].type=="checkbox")
            input[i].checked = b;
    }

    
}
$(document).on( "click",  "#register", function(e){
	var url = "{{ route('easemob.register.user') }}";
	var form = $('#js-form');
	$.post(url, form.serialize(), function(data){
	    }, 'json').error(function(data){
	    	var obj = $.parseJSON(data.responseText);
		    }).success(function(data){
				layer.msg('注册成功');
				location.reload();
	 });
})
$(document).on( "click",  "#updatepass", function(e){
	var url = "{{ route('easemob.updatepass.user') }}";
	var form = $('#js-form');
	$.post(url, form.serialize(), function(data){
	    }, 'json').error(function(data){
	    	var obj = $.parseJSON(data.responseText);
		    }).success(function(data){
				layer.msg('更新成功');
				location.reload();
	 });
})
$(document).on( "click",  "#deleteuser", function(e){
	var url = "{{ route('easemob.delete.user') }}";
	var form = $('#js-form');
	$.post(url, form.serialize(), function(data){
	    }, 'json').error(function(data){
	    	var obj = $.parseJSON(data.responseText);
		    }).success(function(data){
				layer.msg('删除成功');
				location.reload();
	 });
})
</SCRIPT>
@show

